Step 2: NPM

There is a lively ecosystem around JavaScript in general and Node in particular. Moreover, the community embraced open-source projects. As a result, a plethora of Node libraries and applications are published, and many more are added every day. These projects, called Node packages, are published through Node Package Manager or NPM.

NPM is, first and foremost, an online repository of Node projects. NPM is the world's largest software registry at the time of writing, with more than two million records.

Node packages are like building blocks you can put together to make a software application.

You can search for packages at http://npmjs.org/. For example, the React library can be found at https://www.npmjs.com/package/react.

NPM also provides a command-line interface (CLI) that assists with package installation and dependency management. The NPM CLI is installed with Node. You must have it on your computer! Open the terminal and try:

npm -help

In this course, we have been using Yarn, an alternative to NPM that is faster and more resilient.

Open the terminal and run the following command at the hello-node folder.

yarn init -y

The command will create a package.json file inside the hello-node folder.

{
  "name": "hello-node",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT"
}

By convention, every Node application (package) has a package.json file at its root folder. We have seen this file before inside Vite applications. Recall this file holds metadata relevant to the project. It is also used, by Yarn, for managing the project's dependencies, scripts, version, and a lot more.

Aside: PNPM is an alternative to NPM and Yarn.